package xyz.hrz.service.mq;

import com.jfinal.plugin.redis.Redis;
import redis.clients.jedis.BinaryJedisPubSub;

/**
 * 消息接收线程
 * @author hrz
 * @description
 * @create: 2019-10-20
 */
public class MQRedisSub extends BinaryJedisPubSub implements Runnable {


    @Override
    public void onMessage(byte[] channel, byte[] message) {
        super.onMessage(channel, message);
        System.out.println("channel:" + new String(channel));
        System.out.println("receives message :" + new String(message) );
        System.out.println("处理消息" );


    }

    public void run() {// 订阅消息
        Redis.use().getJedis().subscribe(new MQRedisSub(), "msg".getBytes());
    }
}